package com.appwoo.txtws.activity;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.net.Uri;
import android.os.Bundle;
import com.appwoo.txtws.component.Logger;
import com.appwoo.txtws.component.RqSP;
import com.appwoo.txtws.service.RQUpdate;
import java.io.File;
import java.util.Date;

public class UpdateActivity extends Activity
{
  private String inDownPath;
  private RQUpdate ru;

  private void installApk(String paramString)
  {
    SharedPreferences.Editor localEditor = getSharedPreferences("sys", 0).edit();
    localEditor.putInt("isupload", 1);
    localEditor.commit();
    File localFile = new File(paramString);
    Intent localIntent = new Intent();
    localIntent.addFlags(268435456);
    localIntent.setAction("android.intent.action.VIEW");
    localIntent.setDataAndType(Uri.fromFile(localFile), "application/vnd.android.package-archive");
    startActivity(localIntent);
  }

  public boolean isSDCard()
  {
    try
    {
      long l = new Date().getTime();
      File localFile = new File("/sdcard/" + l + ".test");
      boolean bool = localFile.createNewFile();
      localFile.delete();
      Logger.i("xjf", "UpdateActivity--SDCard can use");
      return bool;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
      Logger.i("xjf", "UpdateActivity--No SDCard!!");
    }
    return false;
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903223);
    this.ru = new RQUpdate();
    RqSP localRqSP = new RqSP();
    if (localRqSP.getUpdateVal(this) == 0)
    {
      Logger.v("vol", "开始升级");
      Intent localIntent = new Intent("send.cancle.message");
      localIntent.putExtra("updateval", 1);
      sendBroadcast(localIntent);
      localRqSP.setUpdateVal(1, this);
    }
  }

  protected void onResume()
  {
    super.onResume();
    if (this.ru == null)
      this.ru = new RQUpdate();
    if (this.ru.checkApk(this))
    {
      if (isSDCard())
        installApk(RQUpdate.filePath);
    }
    else
      return;
    this.inDownPath = (getFilesDir().getParent() + File.separator + getFilesDir().getName());
    installApk(this.inDownPath + File.separator + "00.apk");
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.activity.UpdateActivity
 * JD-Core Version:    0.6.2
 */